//
//  WKNiuwaCell.m
//  V-Learn
//
//  Created by Apple on 2019/3/21.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "WKNiuwaCell.h"

@implementation WKNiuwaCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    return self;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifferCell = @"WKNiuwaCell";
    WKNiuwaCell *cell = [tableView dequeueReusableCellWithIdentifier:identifferCell];
    if (!cell) {
        cell = [[WKNiuwaCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifferCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    return cell;
}
- (void)setupUI{
    
    UIView *bgView = [UIView new];
    bgView.frame = CGRectMake(0, 0, ScreenW, 80*kScaleFit);
    [self.contentView addSubview:bgView];
    bgView.backgroundColor = [UIColor whiteColor];
    //    [bgView makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.top.right.mas_equalTo(0);
    //        make.height.mas_equalTo(80*kScaleFit);
    //    }];
    
    
    self.icon = [[UIImageView alloc] init];
    self.icon.image = [UIImage imageNamed:@"vkboy"];
    self.icon.layer.cornerRadius = 22.5;
    self.icon.layer.masksToBounds = YES;
    
    [bgView addSubview:self.icon];
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.centerY.mas_equalTo(bgView);
        make.size.mas_equalTo(CGSizeMake(45*kScaleFit, 45*kScaleFit));
    }];
    
    self.nickLab = [UILabel labelWithText:@"何以繁华笙歌落" andTextColor:rgb(51,51,51) andName:nil andFontSize:15*kScaleFit];
    [bgView addSubview:self.nickLab];
    [self.nickLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).mas_equalTo(10*kScaleFit);
        make.top.mas_equalTo(self.icon.mas_top);
        make.right.mas_equalTo(-40*kScaleFit);
    }];
    
    self.timeLab = [UILabel labelWithText:@"18:09" andTextColor:rgb(102,102,102) andName:nil andFontSize:12*kScaleFit];
    [bgView addSubview:self.timeLab];
    [self.timeLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).mas_equalTo(10*kScaleFit);
        make.top.mas_equalTo(self.nickLab.mas_bottom).mas_equalTo(10*kScaleFit);
        make.right.mas_equalTo(-40*kScaleFit);
    }];
    
    
    self.followButton = [[UIButton alloc] init];
    [bgView addSubview:self.followButton];
    //    [self.followButton setTitle:@"" forState:UIControlStateNormal];
    
    self.followButton.layer.cornerRadius = 12;
    self.followButton.layer.masksToBounds = YES;
    [self.followButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    self.followButton.titleLabel.font = LBFont(12*kScaleFit);
    [self.followButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15*kScaleFit);
        make.centerY.mas_equalTo(bgView);
        make.size.mas_equalTo(CGSizeMake(60*kScaleFit, 24*kScaleFit));
    }];
//    [self.followButton addTarget:self action:@selector(clickFollowBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    self.titleLab = [UILabel labelWithText:@"万思乐学 小西妈双语工程 20180725008  耿思悦201503 北京 28次 20181026" andTextColor:rgb(51,51,51) andName:nil andFontSize:14*kScaleFit];
    [self.contentView addSubview:self.titleLab];
    self.titleLab.numberOfLines = 2;
    [self.titleLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.top.mas_equalTo(bgView.mas_bottom);
        make.right.mas_equalTo(-30*kScaleFit);
    }];
    
    self.detailLab = [UILabel labelWithText:@"主题课程1级 第一课时" andTextColor:rgb(102,102,102) andName:nil andFontSize:12*kScaleFit];
    [self.contentView addSubview:self.detailLab];
    [self.detailLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.top.mas_equalTo(self.titleLab.mas_bottom).mas_equalTo(10*kScaleFit);
        make.right.mas_equalTo(-15*kScaleFit);
    }];
    
    self.bigIcon = [[UIImageView alloc] init];
    self.bigIcon.image = [UIImage imageNamed:@"wk_list_bgimg"];
    [self.contentView addSubview:self.bigIcon];
    [self.bigIcon makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.right.mas_equalTo(-15*kScaleFit);
        make.top.mas_equalTo(self.detailLab.mas_bottom).mas_equalTo(10*kScaleFit);
        make.height.mas_equalTo(190);
    }];
    
    self.playIcon = [[UIImageView alloc] init];
    self.playIcon.image = [UIImage imageNamed:@"play"];
    self.playIcon.layer.cornerRadius = 27.5;
    self.playIcon.layer.masksToBounds = YES;
    
    [self.bigIcon addSubview:self.playIcon];
    [self.playIcon makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.bigIcon);
        make.centerX.mas_equalTo(self.bigIcon);
        make.size.mas_equalTo(CGSizeMake(30*kScaleFit, 30*kScaleFit));
    }];
    
    self.descLab = [UILabel labelWithText:@"Lucia家，不温不火的状态，从从容容地按自己的进度启蒙，我喜欢这样首先把自己的事做好，能有持久战斗力..." andTextColor:rgb(102,102,102) andName:nil andFontSize:14*kScaleFit];
    [self.contentView addSubview:self.descLab];
    self.descLab.numberOfLines = 2;
    [self.descLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*kScaleFit);
        make.top.mas_equalTo(self.bigIcon.mas_bottom).mas_equalTo(10*kScaleFit);
        make.right.mas_equalTo(-15*kScaleFit);
    }];
    
    
    UIView *bottomView = [UIView new];
    
    [self.contentView addSubview:bottomView];
    bottomView.backgroundColor = [UIColor whiteColor];
    [bottomView makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.descLab.mas_bottom);
    }];
    
    self.zanButton = [[UIButton alloc] init];
    [bottomView addSubview:self.zanButton];
    [self.zanButton setTitle:@"0" forState:UIControlStateNormal];
    [self.zanButton setTitleColor:rgb(102,102,102) forState:UIControlStateNormal];
    [self.zanButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 3, 0, 0)];
    [self.zanButton setImageEdgeInsets:UIEdgeInsetsMake(0, -3, 0, 0)];
    [self.zanButton setImage:LBImage(@"wk_unFabulous") forState:UIControlStateNormal];
    
    self.zanButton.titleLabel.font = LBFont(12*kScaleFit);
    [self.zanButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10*kScaleFit);
        make.centerY.mas_equalTo(bottomView);
        make.size.mas_equalTo(CGSizeMake(60*kScaleFit, 24*kScaleFit));
    }];
    UIView *footersectionView = [UIView new];
    footersectionView.backgroundColor = rgb(242,242,242);
    [self.contentView addSubview:footersectionView];
    [footersectionView makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(10);
    }];
    
}
- (void)setModel:(WKHotmenModel *)model{
    _model = model;
    
    NSString *urlstring = [NSString stringWithFormat:@"%@%@",Public_URL,model.headImg];
    [self.icon sd_setImageWithURL:[NSURL URLWithString:urlstring] placeholderImage:[UIImage imageNamed:@"vkboy"]];
    self.nickLab.text = model.username;
    self.timeLab.text = [model.clockDate substringToIndex:10];
    self.titleLab.text = model.clockTitle;
    self.detailLab.text = model.clockOrtherTitle;
    if (model.clockInfoVOList.count>0) {
        WKHotclockInfoVOListModel *model2 = model.clockInfoVOList[0];
        NSString *bigurlstring = [NSString stringWithFormat:@"%@%@",Public_URL,model2.infoFile];
        [self.bigIcon sd_setImageWithURL:[NSURL URLWithString:bigurlstring] placeholderImage:[UIImage imageNamed:@"wk_list_bgimg"]];
        self.descLab.text = model2.infoContent;
    }
    if ([model.isPrase isEqualToString:@"1"]) {
        [self.zanButton setImage:LBImage(@"wk_Fabulous") forState:UIControlStateNormal];
    }else{
        [self.zanButton setImage:LBImage(@"wk_unFabulous") forState:UIControlStateNormal];
    }
    [self.zanButton setTitle:model.praiseNum forState:UIControlStateNormal];
    self.playIcon.hidden = YES;
}
//- (void)setFollowModel:(WKHotmenModel *)followModel{
//    _followModel = followModel;
//    NSString *urlstring = [NSString stringWithFormat:@"%@%@",Public_URL,followModel.headImg];
//    [self.icon sd_setImageWithURL:[NSURL URLWithString:urlstring] placeholderImage:[UIImage imageNamed:@"logo"]];
//    self.nickLab.text = followModel.username;
//    self.timeLab.text = [followModel.clockDate substringToIndex:10];
//    self.titleLab.text = followModel.clockTitle;
//
//    if (followModel.clockInfoVOList.count>0) {
//        WKHotclockInfoVOListModel *model2 = followModel.clockInfoVOList[0];
//        NSString *bigurlstring = [NSString stringWithFormat:@"%@%@",Public_URL,model2.infoFile];
//        [self.bigIcon sd_setImageWithURL:[NSURL URLWithString:bigurlstring] placeholderImage:[UIImage imageNamed:@"kaifeng"]];
//        self.descLab.text = model2.infoContent;
//    }
//    if ([followModel.isPrase isEqualToString:@"1"]) {
//        [self.zanButton setImage:LBImage(@"wk_Fabulous") forState:UIControlStateNormal];
//    }else{
//        [self.zanButton setImage:LBImage(@"wk_unFabulous") forState:UIControlStateNormal];
//    }
//    [self.zanButton setTitle:followModel.praiseNum forState:UIControlStateNormal];
//}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
